Tutorial ObjectivesΒΆ

In this tutorial, we will use the DataArray and Dataset objects, which are used to represent and manipulate spatial data, to practice organizing large global climate datasets and to understand variations in Earth's climate system.

SetupΒΆ

InΒ [1]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import xarray as xr
from pythia_datasets import DATASETS
InΒ [2]:
#!python -m pip install xarray
#!pip install pythia-datasets

Introducing the DataArray and DatasetΒΆ

Xarray expands on the capabilities on NumPy arrays, providing a lot of streamlined data manipulation. It is similar in that respect to Pandas, but whereas Pandas excels at working with tabular data, Xarray is focused on N-dimensional arrays of data (i.e. grids). Its interface is based largely on the netCDF data model (variables, attributes, and dimensions), but it goes beyond the traditional netCDF interfaces to provide functionality similar to netCDF-java's Common Data Model (CDM).

The DataArray is one of the basic building blocks of Xarray (see docs here). It provides a numpy.ndarray-like object that expands to provide two critical pieces of functionality:

  1. Coordinate names and values are stored with the data, making slicing and indexing much more powerful
  2. It has a built-in container for attribues

Here we'll initialize a DataArray object by wrapping a plain NumPy array, and explore a few of its properes.

InΒ [3]:
rand_data = 283 + 5 * np.random.randn(5, 3, 4)
times_index = pd.date_range("2018-01-01", periods=5)
lats = np.linspace(25, 55, 3)
lons = np.linspace(-120, -60, 4)
temperature = xr.DataArray(
    rand_data, coords=[times_index, lats, lons], dims=["time", "lat", "lon"]
)
temperature.attrs["units"] = "kelvin"
temperature.attrs["standard_name"] = "air_temperature"
temperature
Out[3]:
<xarray.DataArray (time: 5, lat: 3, lon: 4)>
array([[[279.08068969, 283.59924455, 278.88855979, 288.84100563],
        [280.42607943, 282.03757895, 283.50546376, 288.4402472 ],
        [283.21125519, 281.47908438, 282.46618897, 284.2257862 ]],

       [[288.64933027, 281.60783505, 287.48939211, 288.79654038],
        [276.09090836, 278.06162429, 279.49107038, 287.45492203],
        [277.23448988, 279.74848988, 273.2099631 , 288.72488109]],

       [[281.58282847, 279.14858514, 288.69770216, 287.0175155 ],
        [295.30767513, 272.92636326, 281.70148717, 277.5746907 ],
        [284.75858158, 285.32928055, 281.2865914 , 284.37681734]],

       [[281.2500776 , 283.66500288, 277.56927955, 295.93838356],
        [296.77521033, 281.90233198, 289.0520211 , 281.93973142],
        [283.8068068 , 282.91001861, 282.91501991, 282.54039077]],

       [[281.5444818 , 292.65168083, 278.94814111, 279.09681217],
        [274.12890448, 282.27473179, 272.96200683, 278.9716441 ],
        [285.88570568, 286.57832943, 285.92709002, 273.71637259]]])
Coordinates:
  * time     (time) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-01-05
  * lat      (lat) float64 25.0 40.0 55.0
  * lon      (lon) float64 -120.0 -100.0 -80.0 -60.0
Attributes:
    units:          kelvin
    standard_name:  air_temperature
xarray.DataArray
  • time: 5
  • lat: 3
  • lon: 4
  • 279.1 283.6 278.9 288.8 280.4 282.0 ... 279.0 285.9 286.6 285.9 273.7
    array([[[279.08068969, 283.59924455, 278.88855979, 288.84100563],
            [280.42607943, 282.03757895, 283.50546376, 288.4402472 ],
            [283.21125519, 281.47908438, 282.46618897, 284.2257862 ]],
    
           [[288.64933027, 281.60783505, 287.48939211, 288.79654038],
            [276.09090836, 278.06162429, 279.49107038, 287.45492203],
            [277.23448988, 279.74848988, 273.2099631 , 288.72488109]],
    
           [[281.58282847, 279.14858514, 288.69770216, 287.0175155 ],
            [295.30767513, 272.92636326, 281.70148717, 277.5746907 ],
            [284.75858158, 285.32928055, 281.2865914 , 284.37681734]],
    
           [[281.2500776 , 283.66500288, 277.56927955, 295.93838356],
            [296.77521033, 281.90233198, 289.0520211 , 281.93973142],
            [283.8068068 , 282.91001861, 282.91501991, 282.54039077]],
    
           [[281.5444818 , 292.65168083, 278.94814111, 279.09681217],
            [274.12890448, 282.27473179, 272.96200683, 278.9716441 ],
            [285.88570568, 286.57832943, 285.92709002, 273.71637259]]])
    • time
      (time)
      datetime64[ns]
      2018-01-01 ... 2018-01-05
      array(['2018-01-01T00:00:00.000000000', '2018-01-02T00:00:00.000000000',
             '2018-01-03T00:00:00.000000000', '2018-01-04T00:00:00.000000000',
             '2018-01-05T00:00:00.000000000'], dtype='datetime64[ns]')
    • lat
      (lat)
      float64
      25.0 40.0 55.0
      array([25., 40., 55.])
    • lon
      (lon)
      float64
      -120.0 -100.0 -80.0 -60.0
      array([-120., -100.,  -80.,  -60.])
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
                     '2018-01-05'],
                    dtype='datetime64[ns]', name='time', freq='D'))
    • lat
      PandasIndex
      PandasIndex(Index([25.0, 40.0, 55.0], dtype='float64', name='lat'))
    • lon
      PandasIndex
      PandasIndex(Index([-120.0, -100.0, -80.0, -60.0], dtype='float64', name='lon'))
  • units :
    kelvin
    standard_name :
    air_temperature
Attributes Are Not Preserved by Default!ΒΆ

Notice what happens if we perform a mathematical operation with the DataArray: the coordinate values persist, but the attributes are lost. This is done because it is very challenging to know if the attribute metadata is still correct or appropriate after arbitrary arithmetic operations.

To illustrate this, we'll do a simple unit conversion from Kelvin to Celsius:

InΒ [4]:
temperature_in_celsius = temperature - 273.15
temperature_in_celsius
Out[4]:
<xarray.DataArray (time: 5, lat: 3, lon: 4)>
array([[[ 5.93068969, 10.44924455,  5.73855979, 15.69100563],
        [ 7.27607943,  8.88757895, 10.35546376, 15.2902472 ],
        [10.06125519,  8.32908438,  9.31618897, 11.0757862 ]],

       [[15.49933027,  8.45783505, 14.33939211, 15.64654038],
        [ 2.94090836,  4.91162429,  6.34107038, 14.30492203],
        [ 4.08448988,  6.59848988,  0.0599631 , 15.57488109]],

       [[ 8.43282847,  5.99858514, 15.54770216, 13.8675155 ],
        [22.15767513, -0.22363674,  8.55148717,  4.4246907 ],
        [11.60858158, 12.17928055,  8.1365914 , 11.22681734]],

       [[ 8.1000776 , 10.51500288,  4.41927955, 22.78838356],
        [23.62521033,  8.75233198, 15.9020211 ,  8.78973142],
        [10.6568068 ,  9.76001861,  9.76501991,  9.39039077]],

       [[ 8.3944818 , 19.50168083,  5.79814111,  5.94681217],
        [ 0.97890448,  9.12473179, -0.18799317,  5.8216441 ],
        [12.73570568, 13.42832943, 12.77709002,  0.56637259]]])
Coordinates:
  * time     (time) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-01-05
  * lat      (lat) float64 25.0 40.0 55.0
  * lon      (lon) float64 -120.0 -100.0 -80.0 -60.0
xarray.DataArray
  • time: 5
  • lat: 3
  • lon: 4
  • 5.931 10.45 5.739 15.69 7.276 8.888 ... 5.822 12.74 13.43 12.78 0.5664
    array([[[ 5.93068969, 10.44924455,  5.73855979, 15.69100563],
            [ 7.27607943,  8.88757895, 10.35546376, 15.2902472 ],
            [10.06125519,  8.32908438,  9.31618897, 11.0757862 ]],
    
           [[15.49933027,  8.45783505, 14.33939211, 15.64654038],
            [ 2.94090836,  4.91162429,  6.34107038, 14.30492203],
            [ 4.08448988,  6.59848988,  0.0599631 , 15.57488109]],
    
           [[ 8.43282847,  5.99858514, 15.54770216, 13.8675155 ],
            [22.15767513, -0.22363674,  8.55148717,  4.4246907 ],
            [11.60858158, 12.17928055,  8.1365914 , 11.22681734]],
    
           [[ 8.1000776 , 10.51500288,  4.41927955, 22.78838356],
            [23.62521033,  8.75233198, 15.9020211 ,  8.78973142],
            [10.6568068 ,  9.76001861,  9.76501991,  9.39039077]],
    
           [[ 8.3944818 , 19.50168083,  5.79814111,  5.94681217],
            [ 0.97890448,  9.12473179, -0.18799317,  5.8216441 ],
            [12.73570568, 13.42832943, 12.77709002,  0.56637259]]])
    • time
      (time)
      datetime64[ns]
      2018-01-01 ... 2018-01-05
      array(['2018-01-01T00:00:00.000000000', '2018-01-02T00:00:00.000000000',
             '2018-01-03T00:00:00.000000000', '2018-01-04T00:00:00.000000000',
             '2018-01-05T00:00:00.000000000'], dtype='datetime64[ns]')
    • lat
      (lat)
      float64
      25.0 40.0 55.0
      array([25., 40., 55.])
    • lon
      (lon)
      float64
      -120.0 -100.0 -80.0 -60.0
      array([-120., -100.,  -80.,  -60.])
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
                     '2018-01-05'],
                    dtype='datetime64[ns]', name='time', freq='D'))
    • lat
      PandasIndex
      PandasIndex(Index([25.0, 40.0, 55.0], dtype='float64', name='lat'))
    • lon
      PandasIndex
      PandasIndex(Index([-120.0, -100.0, -80.0, -60.0], dtype='float64', name='lon'))

We usually wish to keep metadata with our dataset, even after manipulating the data. For example it can tell us what the units are of a variable of interest. So when you perform operations on your data, make sure to check that all the information you want is carried over. If it isn't, you can add it back in following the instructions in the section before this. For an in-depth discussion of how Xarray handles metadata, you can find more information in the Xarray documents here.

InΒ [5]:
# pressure data
pressure_data = 1000.0 + 5 * np.random.randn(5, 3, 4)
pressure = xr.DataArray(
    pressure_data, coords=[times_index, lats, lons], dims=["time", "lat", "lon"]
)
pressure.attrs["units"] = "hPa"
pressure.attrs["standard_name"] = "air_pressure"
pressure
Out[5]:
<xarray.DataArray (time: 5, lat: 3, lon: 4)>
array([[[1004.09013705,  997.55749669,  993.48916981,  993.0873063 ],
        [1002.55612816, 1005.03102607, 1004.53055933,  997.49139616],
        [1002.66542646, 1004.95624469, 1003.99720029, 1003.55310655]],

       [[ 995.46306605,  997.22785491, 1008.58203301, 1003.47860587],
        [1002.27230198,  996.40483294,  998.32749965,  992.63410427],
        [1001.34288171, 1002.08756145, 1000.99191185,  998.12386324]],

       [[ 995.12991502,  998.14040924, 1003.65294855,  999.23142596],
        [ 998.48632029, 1002.78450029,  996.94938813,  997.55294349],
        [1000.79924184, 1001.90194949, 1000.86605601, 1002.01982823]],

       [[1002.81042554,  992.35819213,  996.11475225, 1007.25011068],
        [ 990.39238393,  994.34456897,  999.17569625, 1003.73974126],
        [ 998.17138846,  997.79472633, 1001.59398293,  991.75633904]],

       [[ 996.16869963, 1001.61325756,  997.86510094,  998.25079313],
        [ 988.98152828,  997.89675818, 1004.44665353,  994.12893442],
        [ 998.25549271,  996.14930485,  998.24734721,  996.26258376]]])
Coordinates:
  * time     (time) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-01-05
  * lat      (lat) float64 25.0 40.0 55.0
  * lon      (lon) float64 -120.0 -100.0 -80.0 -60.0
Attributes:
    units:          hPa
    standard_name:  air_pressure
xarray.DataArray
  • time: 5
  • lat: 3
  • lon: 4
  • 1.004e+03 997.6 993.5 993.1 1.003e+03 ... 998.3 996.1 998.2 996.3
    array([[[1004.09013705,  997.55749669,  993.48916981,  993.0873063 ],
            [1002.55612816, 1005.03102607, 1004.53055933,  997.49139616],
            [1002.66542646, 1004.95624469, 1003.99720029, 1003.55310655]],
    
           [[ 995.46306605,  997.22785491, 1008.58203301, 1003.47860587],
            [1002.27230198,  996.40483294,  998.32749965,  992.63410427],
            [1001.34288171, 1002.08756145, 1000.99191185,  998.12386324]],
    
           [[ 995.12991502,  998.14040924, 1003.65294855,  999.23142596],
            [ 998.48632029, 1002.78450029,  996.94938813,  997.55294349],
            [1000.79924184, 1001.90194949, 1000.86605601, 1002.01982823]],
    
           [[1002.81042554,  992.35819213,  996.11475225, 1007.25011068],
            [ 990.39238393,  994.34456897,  999.17569625, 1003.73974126],
            [ 998.17138846,  997.79472633, 1001.59398293,  991.75633904]],
    
           [[ 996.16869963, 1001.61325756,  997.86510094,  998.25079313],
            [ 988.98152828,  997.89675818, 1004.44665353,  994.12893442],
            [ 998.25549271,  996.14930485,  998.24734721,  996.26258376]]])
    • time
      (time)
      datetime64[ns]
      2018-01-01 ... 2018-01-05
      array(['2018-01-01T00:00:00.000000000', '2018-01-02T00:00:00.000000000',
             '2018-01-03T00:00:00.000000000', '2018-01-04T00:00:00.000000000',
             '2018-01-05T00:00:00.000000000'], dtype='datetime64[ns]')
    • lat
      (lat)
      float64
      25.0 40.0 55.0
      array([25., 40., 55.])
    • lon
      (lon)
      float64
      -120.0 -100.0 -80.0 -60.0
      array([-120., -100.,  -80.,  -60.])
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
                     '2018-01-05'],
                    dtype='datetime64[ns]', name='time', freq='D'))
    • lat
      PandasIndex
      PandasIndex(Index([25.0, 40.0, 55.0], dtype='float64', name='lat'))
    • lon
      PandasIndex
      PandasIndex(Index([-120.0, -100.0, -80.0, -60.0], dtype='float64', name='lon'))
  • units :
    hPa
    standard_name :
    air_pressure
InΒ [6]:
# combinate temperature and pressure DataArrays into a Dataset called 'ds'
ds = xr.Dataset(data_vars={"Temperature": temperature, "Pressure": pressure})
ds
Out[6]:
<xarray.Dataset>
Dimensions:      (time: 5, lat: 3, lon: 4)
Coordinates:
  * time         (time) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-01-05
  * lat          (lat) float64 25.0 40.0 55.0
  * lon          (lon) float64 -120.0 -100.0 -80.0 -60.0
Data variables:
    Temperature  (time, lat, lon) float64 279.1 283.6 278.9 ... 285.9 273.7
    Pressure     (time, lat, lon) float64 1.004e+03 997.6 993.5 ... 998.2 996.3
xarray.Dataset
    • time: 5
    • lat: 3
    • lon: 4
    • time
      (time)
      datetime64[ns]
      2018-01-01 ... 2018-01-05
      array(['2018-01-01T00:00:00.000000000', '2018-01-02T00:00:00.000000000',
             '2018-01-03T00:00:00.000000000', '2018-01-04T00:00:00.000000000',
             '2018-01-05T00:00:00.000000000'], dtype='datetime64[ns]')
    • lat
      (lat)
      float64
      25.0 40.0 55.0
      array([25., 40., 55.])
    • lon
      (lon)
      float64
      -120.0 -100.0 -80.0 -60.0
      array([-120., -100.,  -80.,  -60.])
    • Temperature
      (time, lat, lon)
      float64
      279.1 283.6 278.9 ... 285.9 273.7
      units :
      kelvin
      standard_name :
      air_temperature
      array([[[279.08068969, 283.59924455, 278.88855979, 288.84100563],
              [280.42607943, 282.03757895, 283.50546376, 288.4402472 ],
              [283.21125519, 281.47908438, 282.46618897, 284.2257862 ]],
      
             [[288.64933027, 281.60783505, 287.48939211, 288.79654038],
              [276.09090836, 278.06162429, 279.49107038, 287.45492203],
              [277.23448988, 279.74848988, 273.2099631 , 288.72488109]],
      
             [[281.58282847, 279.14858514, 288.69770216, 287.0175155 ],
              [295.30767513, 272.92636326, 281.70148717, 277.5746907 ],
              [284.75858158, 285.32928055, 281.2865914 , 284.37681734]],
      
             [[281.2500776 , 283.66500288, 277.56927955, 295.93838356],
              [296.77521033, 281.90233198, 289.0520211 , 281.93973142],
              [283.8068068 , 282.91001861, 282.91501991, 282.54039077]],
      
             [[281.5444818 , 292.65168083, 278.94814111, 279.09681217],
              [274.12890448, 282.27473179, 272.96200683, 278.9716441 ],
              [285.88570568, 286.57832943, 285.92709002, 273.71637259]]])
    • Pressure
      (time, lat, lon)
      float64
      1.004e+03 997.6 ... 998.2 996.3
      units :
      hPa
      standard_name :
      air_pressure
      array([[[1004.09013705,  997.55749669,  993.48916981,  993.0873063 ],
              [1002.55612816, 1005.03102607, 1004.53055933,  997.49139616],
              [1002.66542646, 1004.95624469, 1003.99720029, 1003.55310655]],
      
             [[ 995.46306605,  997.22785491, 1008.58203301, 1003.47860587],
              [1002.27230198,  996.40483294,  998.32749965,  992.63410427],
              [1001.34288171, 1002.08756145, 1000.99191185,  998.12386324]],
      
             [[ 995.12991502,  998.14040924, 1003.65294855,  999.23142596],
              [ 998.48632029, 1002.78450029,  996.94938813,  997.55294349],
              [1000.79924184, 1001.90194949, 1000.86605601, 1002.01982823]],
      
             [[1002.81042554,  992.35819213,  996.11475225, 1007.25011068],
              [ 990.39238393,  994.34456897,  999.17569625, 1003.73974126],
              [ 998.17138846,  997.79472633, 1001.59398293,  991.75633904]],
      
             [[ 996.16869963, 1001.61325756,  997.86510094,  998.25079313],
              [ 988.98152828,  997.89675818, 1004.44665353,  994.12893442],
              [ 998.25549271,  996.14930485,  998.24734721,  996.26258376]]])
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
                     '2018-01-05'],
                    dtype='datetime64[ns]', name='time', freq='D'))
    • lat
      PandasIndex
      PandasIndex(Index([25.0, 40.0, 55.0], dtype='float64', name='lat'))
    • lon
      PandasIndex
      PandasIndex(Index([-120.0, -100.0, -80.0, -60.0], dtype='float64', name='lon'))
InΒ [7]:
# We can pull out any of the individual DataArray objects in a few different ways.
# Using the dictionary access like this:
ds["Temperature"]
Out[7]:
<xarray.DataArray 'Temperature' (time: 5, lat: 3, lon: 4)>
array([[[279.08068969, 283.59924455, 278.88855979, 288.84100563],
        [280.42607943, 282.03757895, 283.50546376, 288.4402472 ],
        [283.21125519, 281.47908438, 282.46618897, 284.2257862 ]],

       [[288.64933027, 281.60783505, 287.48939211, 288.79654038],
        [276.09090836, 278.06162429, 279.49107038, 287.45492203],
        [277.23448988, 279.74848988, 273.2099631 , 288.72488109]],

       [[281.58282847, 279.14858514, 288.69770216, 287.0175155 ],
        [295.30767513, 272.92636326, 281.70148717, 277.5746907 ],
        [284.75858158, 285.32928055, 281.2865914 , 284.37681734]],

       [[281.2500776 , 283.66500288, 277.56927955, 295.93838356],
        [296.77521033, 281.90233198, 289.0520211 , 281.93973142],
        [283.8068068 , 282.91001861, 282.91501991, 282.54039077]],

       [[281.5444818 , 292.65168083, 278.94814111, 279.09681217],
        [274.12890448, 282.27473179, 272.96200683, 278.9716441 ],
        [285.88570568, 286.57832943, 285.92709002, 273.71637259]]])
Coordinates:
  * time     (time) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-01-05
  * lat      (lat) float64 25.0 40.0 55.0
  * lon      (lon) float64 -120.0 -100.0 -80.0 -60.0
Attributes:
    units:          kelvin
    standard_name:  air_temperature
xarray.DataArray
'Temperature'
  • time: 5
  • lat: 3
  • lon: 4
  • 279.1 283.6 278.9 288.8 280.4 282.0 ... 279.0 285.9 286.6 285.9 273.7
    array([[[279.08068969, 283.59924455, 278.88855979, 288.84100563],
            [280.42607943, 282.03757895, 283.50546376, 288.4402472 ],
            [283.21125519, 281.47908438, 282.46618897, 284.2257862 ]],
    
           [[288.64933027, 281.60783505, 287.48939211, 288.79654038],
            [276.09090836, 278.06162429, 279.49107038, 287.45492203],
            [277.23448988, 279.74848988, 273.2099631 , 288.72488109]],
    
           [[281.58282847, 279.14858514, 288.69770216, 287.0175155 ],
            [295.30767513, 272.92636326, 281.70148717, 277.5746907 ],
            [284.75858158, 285.32928055, 281.2865914 , 284.37681734]],
    
           [[281.2500776 , 283.66500288, 277.56927955, 295.93838356],
            [296.77521033, 281.90233198, 289.0520211 , 281.93973142],
            [283.8068068 , 282.91001861, 282.91501991, 282.54039077]],
    
           [[281.5444818 , 292.65168083, 278.94814111, 279.09681217],
            [274.12890448, 282.27473179, 272.96200683, 278.9716441 ],
            [285.88570568, 286.57832943, 285.92709002, 273.71637259]]])
    • time
      (time)
      datetime64[ns]
      2018-01-01 ... 2018-01-05
      array(['2018-01-01T00:00:00.000000000', '2018-01-02T00:00:00.000000000',
             '2018-01-03T00:00:00.000000000', '2018-01-04T00:00:00.000000000',
             '2018-01-05T00:00:00.000000000'], dtype='datetime64[ns]')
    • lat
      (lat)
      float64
      25.0 40.0 55.0
      array([25., 40., 55.])
    • lon
      (lon)
      float64
      -120.0 -100.0 -80.0 -60.0
      array([-120., -100.,  -80.,  -60.])
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
                     '2018-01-05'],
                    dtype='datetime64[ns]', name='time', freq='D'))
    • lat
      PandasIndex
      PandasIndex(Index([25.0, 40.0, 55.0], dtype='float64', name='lat'))
    • lon
      PandasIndex
      PandasIndex(Index([-120.0, -100.0, -80.0, -60.0], dtype='float64', name='lon'))
  • units :
    kelvin
    standard_name :
    air_temperature
InΒ [8]:
# ... or using "dot" notation:
ds.Pressure
Out[8]:
<xarray.DataArray 'Pressure' (time: 5, lat: 3, lon: 4)>
array([[[1004.09013705,  997.55749669,  993.48916981,  993.0873063 ],
        [1002.55612816, 1005.03102607, 1004.53055933,  997.49139616],
        [1002.66542646, 1004.95624469, 1003.99720029, 1003.55310655]],

       [[ 995.46306605,  997.22785491, 1008.58203301, 1003.47860587],
        [1002.27230198,  996.40483294,  998.32749965,  992.63410427],
        [1001.34288171, 1002.08756145, 1000.99191185,  998.12386324]],

       [[ 995.12991502,  998.14040924, 1003.65294855,  999.23142596],
        [ 998.48632029, 1002.78450029,  996.94938813,  997.55294349],
        [1000.79924184, 1001.90194949, 1000.86605601, 1002.01982823]],

       [[1002.81042554,  992.35819213,  996.11475225, 1007.25011068],
        [ 990.39238393,  994.34456897,  999.17569625, 1003.73974126],
        [ 998.17138846,  997.79472633, 1001.59398293,  991.75633904]],

       [[ 996.16869963, 1001.61325756,  997.86510094,  998.25079313],
        [ 988.98152828,  997.89675818, 1004.44665353,  994.12893442],
        [ 998.25549271,  996.14930485,  998.24734721,  996.26258376]]])
Coordinates:
  * time     (time) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-01-05
  * lat      (lat) float64 25.0 40.0 55.0
  * lon      (lon) float64 -120.0 -100.0 -80.0 -60.0
Attributes:
    units:          hPa
    standard_name:  air_pressure
xarray.DataArray
'Pressure'
  • time: 5
  • lat: 3
  • lon: 4
  • 1.004e+03 997.6 993.5 993.1 1.003e+03 ... 998.3 996.1 998.2 996.3
    array([[[1004.09013705,  997.55749669,  993.48916981,  993.0873063 ],
            [1002.55612816, 1005.03102607, 1004.53055933,  997.49139616],
            [1002.66542646, 1004.95624469, 1003.99720029, 1003.55310655]],
    
           [[ 995.46306605,  997.22785491, 1008.58203301, 1003.47860587],
            [1002.27230198,  996.40483294,  998.32749965,  992.63410427],
            [1001.34288171, 1002.08756145, 1000.99191185,  998.12386324]],
    
           [[ 995.12991502,  998.14040924, 1003.65294855,  999.23142596],
            [ 998.48632029, 1002.78450029,  996.94938813,  997.55294349],
            [1000.79924184, 1001.90194949, 1000.86605601, 1002.01982823]],
    
           [[1002.81042554,  992.35819213,  996.11475225, 1007.25011068],
            [ 990.39238393,  994.34456897,  999.17569625, 1003.73974126],
            [ 998.17138846,  997.79472633, 1001.59398293,  991.75633904]],
    
           [[ 996.16869963, 1001.61325756,  997.86510094,  998.25079313],
            [ 988.98152828,  997.89675818, 1004.44665353,  994.12893442],
            [ 998.25549271,  996.14930485,  998.24734721,  996.26258376]]])
    • time
      (time)
      datetime64[ns]
      2018-01-01 ... 2018-01-05
      array(['2018-01-01T00:00:00.000000000', '2018-01-02T00:00:00.000000000',
             '2018-01-03T00:00:00.000000000', '2018-01-04T00:00:00.000000000',
             '2018-01-05T00:00:00.000000000'], dtype='datetime64[ns]')
    • lat
      (lat)
      float64
      25.0 40.0 55.0
      array([25., 40., 55.])
    • lon
      (lon)
      float64
      -120.0 -100.0 -80.0 -60.0
      array([-120., -100.,  -80.,  -60.])
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
                     '2018-01-05'],
                    dtype='datetime64[ns]', name='time', freq='D'))
    • lat
      PandasIndex
      PandasIndex(Index([25.0, 40.0, 55.0], dtype='float64', name='lat'))
    • lon
      PandasIndex
      PandasIndex(Index([-120.0, -100.0, -80.0, -60.0], dtype='float64', name='lon'))
  • units :
    hPa
    standard_name :
    air_pressure

Global climate datasets can be very large with multiple variables, and DataArrays and Datasets are very useful tools for organizing, comparing and interpreting such data. However, sometimes we are not interested in examining a global dataset but wish to examine a specific time or location. For example, we might want to look at climate variables in a particular region of Earth, and potentially compare that to another region. In order to carry-out such analyses, it’s useful to be able to extract and compare subsets of data from a global dataset. You can explore multiple computational tools in Xarray that allow you to select data from a specific spatial and temporal range, like:g

  • .sel(): select data based on coordinate values or date
  • .interp(): interpolate to any latitude/longitude location to extract data
  • slice(): to select a range (or slice) along one or more coordinates, we can pass a Python slice object to .sel()

Atmospheric Climate SystemsΒΆ

image.png

Many global climate datasets are stored as NetCDF (network Common Data Form) files. NetCDF is a file format for storing multidimensional variables such as temperature, humidity, pressure, wind speed, and direction. These types of files also include metadata that gives you information about the variables and dataset itself.

Xarray is closely linked with the netCDF data model, and it even treats netCDF as a 'first-class' file format. This means that Xarray can easily open netCDF datasets. However, these datasets need to follow some of Xarray's rules. One such rule is that coordinates must be 1-dimensional.

Here we're getting the data from Project Pythia's custom library of example data, which we already imported above with from pythia_datasets import DATASETS. The DATASETS.fetch() method will automatically download and cache (store) our example data file NARR_19930313_0000.nc locally.

InΒ [9]:
filepath = DATASETS.fetch("NARR_19930313_0000.nc")
ds = xr.open_dataset(filepath)
ds
Out[9]:
<xarray.Dataset>
Dimensions:                       (time1: 1, isobaric1: 29, y: 119, x: 268)
Coordinates:
  * time1                         (time1) datetime64[ns] 1993-03-13
  * isobaric1                     (isobaric1) float32 100.0 125.0 ... 1e+03
  * y                             (y) float32 -3.117e+03 -3.084e+03 ... 714.1
  * x                             (x) float32 -3.324e+03 ... 5.343e+03
Data variables:
    u-component_of_wind_isobaric  (time1, isobaric1, y, x) float32 ...
    LambertConformal_Projection   int32 ...
    lat                           (y, x) float64 ...
    lon                           (y, x) float64 ...
    Geopotential_height_isobaric  (time1, isobaric1, y, x) float32 ...
    v-component_of_wind_isobaric  (time1, isobaric1, y, x) float32 ...
    Temperature_isobaric          (time1, isobaric1, y, x) float32 ...
Attributes:
    Originating_or_generating_Center:     US National Weather Service, Nation...
    Originating_or_generating_Subcenter:  North American Regional Reanalysis ...
    GRIB_table_version:                   0,131
    Generating_process_or_model:          North American Regional Reanalysis ...
    Conventions:                          CF-1.6
    history:                              Read using CDM IOSP GribCollection v3
    featureType:                          GRID
    History:                              Translated to CF-1.0 Conventions by...
    geospatial_lat_min:                   10.753308882144761
    geospatial_lat_max:                   46.8308828962289
    geospatial_lon_min:                   -153.88242040519995
    geospatial_lon_max:                   -42.666108129242815
xarray.Dataset
    • time1: 1
    • isobaric1: 29
    • y: 119
    • x: 268
    • time1
      (time1)
      datetime64[ns]
      1993-03-13
      standard_name :
      time
      long_name :
      GRIB forecast or observation time
      _CoordinateAxisType :
      Time
      array(['1993-03-13T00:00:00.000000000'], dtype='datetime64[ns]')
    • isobaric1
      (isobaric1)
      float32
      100.0 125.0 150.0 ... 975.0 1e+03
      units :
      hPa
      long_name :
      Isobaric surface
      positive :
      down
      Grib_level_type :
      100
      _CoordinateAxisType :
      Pressure
      _CoordinateZisPositive :
      down
      array([ 100.,  125.,  150.,  175.,  200.,  225.,  250.,  275.,  300.,  350.,
              400.,  450.,  500.,  550.,  600.,  650.,  700.,  725.,  750.,  775.,
              800.,  825.,  850.,  875.,  900.,  925.,  950.,  975., 1000.],
            dtype=float32)
    • y
      (y)
      float32
      -3.117e+03 -3.084e+03 ... 714.1
      standard_name :
      projection_y_coordinate
      units :
      km
      _CoordinateAxisType :
      GeoY
      array([-3.116548e+03, -3.084085e+03, -3.051622e+03, -3.019159e+03,
             -2.986696e+03, -2.954233e+03, -2.921770e+03, -2.889307e+03,
             -2.856844e+03, -2.824381e+03, -2.791918e+03, -2.759455e+03,
             -2.726992e+03, -2.694529e+03, -2.662066e+03, -2.629603e+03,
             -2.597140e+03, -2.564677e+03, -2.532214e+03, -2.499751e+03,
             -2.467288e+03, -2.434825e+03, -2.402362e+03, -2.369899e+03,
             -2.337436e+03, -2.304973e+03, -2.272510e+03, -2.240047e+03,
             -2.207584e+03, -2.175121e+03, -2.142658e+03, -2.110195e+03,
             -2.077732e+03, -2.045269e+03, -2.012806e+03, -1.980343e+03,
             -1.947880e+03, -1.915417e+03, -1.882954e+03, -1.850491e+03,
             -1.818028e+03, -1.785565e+03, -1.753102e+03, -1.720639e+03,
             -1.688176e+03, -1.655713e+03, -1.623250e+03, -1.590787e+03,
             -1.558324e+03, -1.525861e+03, -1.493398e+03, -1.460935e+03,
             -1.428472e+03, -1.396009e+03, -1.363546e+03, -1.331083e+03,
             -1.298620e+03, -1.266157e+03, -1.233694e+03, -1.201231e+03,
             -1.168768e+03, -1.136305e+03, -1.103842e+03, -1.071379e+03,
             -1.038916e+03, -1.006453e+03, -9.739901e+02, -9.415271e+02,
             -9.090641e+02, -8.766011e+02, -8.441381e+02, -8.116751e+02,
             -7.792121e+02, -7.467491e+02, -7.142861e+02, -6.818231e+02,
             -6.493601e+02, -6.168971e+02, -5.844341e+02, -5.519711e+02,
             -5.195081e+02, -4.870451e+02, -4.545821e+02, -4.221191e+02,
             -3.896561e+02, -3.571931e+02, -3.247301e+02, -2.922671e+02,
             -2.598041e+02, -2.273411e+02, -1.948781e+02, -1.624151e+02,
             -1.299521e+02, -9.748907e+01, -6.502608e+01, -3.256308e+01,
             -1.000744e-01,  3.236293e+01,  6.482593e+01,  9.728893e+01,
              1.297519e+02,  1.622149e+02,  1.946779e+02,  2.271409e+02,
              2.596039e+02,  2.920669e+02,  3.245299e+02,  3.569930e+02,
              3.894559e+02,  4.219189e+02,  4.543820e+02,  4.868449e+02,
              5.193079e+02,  5.517709e+02,  5.842339e+02,  6.166970e+02,
              6.491600e+02,  6.816229e+02,  7.140859e+02], dtype=float32)
    • x
      (x)
      float32
      -3.324e+03 -3.292e+03 ... 5.343e+03
      standard_name :
      projection_x_coordinate
      units :
      km
      _CoordinateAxisType :
      GeoX
      array([-3324.4707, -3292.0078, -3259.5447, ...,  5278.2246,  5310.6875,
              5343.1504], dtype=float32)
    • u-component_of_wind_isobaric
      (time1, isobaric1, y, x)
      float32
      ...
      long_name :
      u-component of wind @ Isobaric surface
      units :
      m s^-1
      description :
      u-component of wind
      grid_mapping :
      LambertConformal_Projection
      Grib_Variable_Id :
      VAR_7-15-131-33_L100
      Grib1_Center :
      7
      Grib1_Subcenter :
      15
      Grib1_TableVersion :
      131
      Grib1_Parameter :
      33
      Grib1_Level_Type :
      100
      Grib1_Level_Desc :
      Isobaric surface
      [924868 values with dtype=float32]
    • LambertConformal_Projection
      ()
      int32
      ...
      grid_mapping_name :
      lambert_conformal_conic
      latitude_of_projection_origin :
      50.000003814697266
      longitude_of_central_meridian :
      -107.00000762939453
      standard_parallel :
      50.000003814697266
      earth_radius :
      6367470.0
      _CoordinateTransformType :
      Projection
      _CoordinateAxisTypes :
      GeoX GeoY
      [1 values with dtype=int32]
    • lat
      (y, x)
      float64
      ...
      units :
      degrees_north
      long_name :
      latitude coordinate
      standard_name :
      latitude
      _CoordinateAxisType :
      Lat
      [31892 values with dtype=float64]
    • lon
      (y, x)
      float64
      ...
      units :
      degrees_east
      long_name :
      longitude coordinate
      standard_name :
      longitude
      _CoordinateAxisType :
      Lon
      [31892 values with dtype=float64]
    • Geopotential_height_isobaric
      (time1, isobaric1, y, x)
      float32
      ...
      long_name :
      Geopotential height @ Isobaric surface
      units :
      gpm
      description :
      Geopotential height
      grid_mapping :
      LambertConformal_Projection
      Grib_Variable_Id :
      VAR_7-15-131-7_L100
      Grib1_Center :
      7
      Grib1_Subcenter :
      15
      Grib1_TableVersion :
      131
      Grib1_Parameter :
      7
      Grib1_Level_Type :
      100
      Grib1_Level_Desc :
      Isobaric surface
      [924868 values with dtype=float32]
    • v-component_of_wind_isobaric
      (time1, isobaric1, y, x)
      float32
      ...
      long_name :
      v-component of wind @ Isobaric surface
      units :
      m s^-1
      description :
      v-component of wind
      grid_mapping :
      LambertConformal_Projection
      Grib_Variable_Id :
      VAR_7-15-131-34_L100
      Grib1_Center :
      7
      Grib1_Subcenter :
      15
      Grib1_TableVersion :
      131
      Grib1_Parameter :
      34
      Grib1_Level_Type :
      100
      Grib1_Level_Desc :
      Isobaric surface
      [924868 values with dtype=float32]
    • Temperature_isobaric
      (time1, isobaric1, y, x)
      float32
      ...
      long_name :
      Temperature @ Isobaric surface
      units :
      K
      description :
      Temperature
      grid_mapping :
      LambertConformal_Projection
      Grib_Variable_Id :
      VAR_7-15-131-11_L100
      Grib1_Center :
      7
      Grib1_Subcenter :
      15
      Grib1_TableVersion :
      131
      Grib1_Parameter :
      11
      Grib1_Level_Type :
      100
      Grib1_Level_Desc :
      Isobaric surface
      [924868 values with dtype=float32]
    • time1
      PandasIndex
      PandasIndex(DatetimeIndex(['1993-03-13'], dtype='datetime64[ns]', name='time1', freq=None))
    • isobaric1
      PandasIndex
      PandasIndex(Index([ 100.0,  125.0,  150.0,  175.0,  200.0,  225.0,  250.0,  275.0,  300.0,
              350.0,  400.0,  450.0,  500.0,  550.0,  600.0,  650.0,  700.0,  725.0,
              750.0,  775.0,  800.0,  825.0,  850.0,  875.0,  900.0,  925.0,  950.0,
              975.0, 1000.0],
            dtype='float32', name='isobaric1'))
    • y
      PandasIndex
      PandasIndex(Index([-3116.548095703125, -3084.085205078125,   -3051.6220703125,
               -3019.1591796875,   -2986.6962890625, -2954.233154296875,
             -2921.770263671875,  -2889.30712890625,  -2856.84423828125,
             -2824.381103515625,
             ...
                 421.9189453125,  454.3819580078125,  486.8449401855469,
              519.3079223632812,  551.7709350585938,  584.2339477539062,
              616.6969604492188,  649.1599731445312,  681.6229248046875,
                    714.0859375],
            dtype='float32', name='y', length=119))
    • x
      PandasIndex
      PandasIndex(Index([   -3324.470703125,      -3292.0078125, -3259.544677734375,
             -3227.081787109375,  -3194.61865234375,  -3162.15576171875,
             -3129.692626953125, -3097.229736328125,   -3064.7666015625,
               -3032.3037109375,
             ...
                5050.9833984375,   5083.44677734375,   5115.90966796875,
               5148.37255859375,   5180.83544921875,     5213.298828125,
                  5245.76171875,     5278.224609375,          5310.6875,
                 5343.150390625],
            dtype='float32', name='x', length=268))
  • Originating_or_generating_Center :
    US National Weather Service, National Centres for Environmental Prediction (NCEP)
    Originating_or_generating_Subcenter :
    North American Regional Reanalysis Project
    GRIB_table_version :
    0,131
    Generating_process_or_model :
    North American Regional Reanalysis (NARR)
    Conventions :
    CF-1.6
    history :
    Read using CDM IOSP GribCollection v3
    featureType :
    GRID
    History :
    Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter2) Original Dataset = DatasetScan#narr-a_221_19930313_0000_000.grb; Translation Date = 2018-01-04T23:57:16.043Z
    geospatial_lat_min :
    10.753308882144761
    geospatial_lat_max :
    46.8308828962289
    geospatial_lon_min :
    -153.88242040519995
    geospatial_lon_max :
    -42.666108129242815
InΒ [10]:
ds.isobaric1
Out[10]:
<xarray.DataArray 'isobaric1' (isobaric1: 29)>
array([ 100.,  125.,  150.,  175.,  200.,  225.,  250.,  275.,  300.,  350.,
        400.,  450.,  500.,  550.,  600.,  650.,  700.,  725.,  750.,  775.,
        800.,  825.,  850.,  875.,  900.,  925.,  950.,  975., 1000.],
      dtype=float32)
Coordinates:
  * isobaric1  (isobaric1) float32 100.0 125.0 150.0 175.0 ... 950.0 975.0 1e+03
Attributes:
    units:                   hPa
    long_name:               Isobaric surface
    positive:                down
    Grib_level_type:         100
    _CoordinateAxisType:     Pressure
    _CoordinateZisPositive:  down
xarray.DataArray
'isobaric1'
  • isobaric1: 29
  • 100.0 125.0 150.0 175.0 200.0 225.0 ... 900.0 925.0 950.0 975.0 1e+03
    array([ 100.,  125.,  150.,  175.,  200.,  225.,  250.,  275.,  300.,  350.,
            400.,  450.,  500.,  550.,  600.,  650.,  700.,  725.,  750.,  775.,
            800.,  825.,  850.,  875.,  900.,  925.,  950.,  975., 1000.],
          dtype=float32)
    • isobaric1
      (isobaric1)
      float32
      100.0 125.0 150.0 ... 975.0 1e+03
      units :
      hPa
      long_name :
      Isobaric surface
      positive :
      down
      Grib_level_type :
      100
      _CoordinateAxisType :
      Pressure
      _CoordinateZisPositive :
      down
      array([ 100.,  125.,  150.,  175.,  200.,  225.,  250.,  275.,  300.,  350.,
              400.,  450.,  500.,  550.,  600.,  650.,  700.,  725.,  750.,  775.,
              800.,  825.,  850.,  875.,  900.,  925.,  950.,  975., 1000.],
            dtype=float32)
    • isobaric1
      PandasIndex
      PandasIndex(Index([ 100.0,  125.0,  150.0,  175.0,  200.0,  225.0,  250.0,  275.0,  300.0,
              350.0,  400.0,  450.0,  500.0,  550.0,  600.0,  650.0,  700.0,  725.0,
              750.0,  775.0,  800.0,  825.0,  850.0,  875.0,  900.0,  925.0,  950.0,
              975.0, 1000.0],
            dtype='float32', name='isobaric1'))
  • units :
    hPa
    long_name :
    Isobaric surface
    positive :
    down
    Grib_level_type :
    100
    _CoordinateAxisType :
    Pressure
    _CoordinateZisPositive :
    down

The isobaric1 coordinate contains 29 pressure values (in hPa) corresponding to different pressures of the atmosphere. Recall from the video that pressure decreases with height in the atmosphere. Therefore, in our dataset lower atmospheric pressure values will correspond to higher altitudes. For each isobaric pressure value, there is data for all other variables in the dataset at that same pressure level of the atmosphere:

  • Wind: the u and v components of the wind describe the direction of wind movement along a pressure level of the atmosphere. The U wind component is parallel to the x-axis (i.e. longitude) and the V wind component is parallel to the y- axis (i.e. latitude).
  • Temperature: temperatures on a specific atmospheric pressure level
  • Geopotential Height: the height of a given point in the atmosphere in units proportional to the potential energy of unit mass (geopotential) at this height relative to sea lrther.

Next, let's try calculating the mean of the temperature profile (temperature as a function of pressure) over a specific region. For this exercise, we will calculate the temperature profile over Colorado, USA. The bounds of Colorado are:

  • x: -182km to 424km
  • y: -1450km to -990km

If you look back at the values for x and y in our dataset, the units for these values are kilometers (km). Remember that they are also the coordinates for the lat and lon variables in our dataset. The bounds for Colorado correspond to the coordinates 37Β°N to 41Β°N and 102Β°W to 109Β°W.

InΒ [11]:
# get the temperature data
temps = ds.Temperature_isobaric

# take just the spatial data we are interested in for Colorado
co_temps = temps.sel(x=slice(-182, 424), y=slice(-1450, -990))

# take the average
prof = co_temps.mean(dim=["x", "y"])
prof
Out[11]:
<xarray.DataArray 'Temperature_isobaric' (time1: 1, isobaric1: 29)>
array([[215.078  , 215.76935, 217.243  , 217.82663, 215.83487, 216.10933,
        219.99902, 224.66118, 228.80576, 234.88701, 238.78503, 242.66309,
        246.44807, 249.26636, 250.84995, 253.37354, 257.0429 , 259.08398,
        260.97955, 262.98364, 264.82138, 266.5198 , 268.22467, 269.7471 ,
        271.18216, 272.66815, 274.13037, 275.54718, 276.97675]],
      dtype=float32)
Coordinates:
  * time1      (time1) datetime64[ns] 1993-03-13
  * isobaric1  (isobaric1) float32 100.0 125.0 150.0 175.0 ... 950.0 975.0 1e+03
xarray.DataArray
'Temperature_isobaric'
  • time1: 1
  • isobaric1: 29
  • 215.1 215.8 217.2 217.8 215.8 216.1 ... 271.2 272.7 274.1 275.5 277.0
    array([[215.078  , 215.76935, 217.243  , 217.82663, 215.83487, 216.10933,
            219.99902, 224.66118, 228.80576, 234.88701, 238.78503, 242.66309,
            246.44807, 249.26636, 250.84995, 253.37354, 257.0429 , 259.08398,
            260.97955, 262.98364, 264.82138, 266.5198 , 268.22467, 269.7471 ,
            271.18216, 272.66815, 274.13037, 275.54718, 276.97675]],
          dtype=float32)
    • time1
      (time1)
      datetime64[ns]
      1993-03-13
      standard_name :
      time
      long_name :
      GRIB forecast or observation time
      _CoordinateAxisType :
      Time
      array(['1993-03-13T00:00:00.000000000'], dtype='datetime64[ns]')
    • isobaric1
      (isobaric1)
      float32
      100.0 125.0 150.0 ... 975.0 1e+03
      units :
      hPa
      long_name :
      Isobaric surface
      positive :
      down
      Grib_level_type :
      100
      _CoordinateAxisType :
      Pressure
      _CoordinateZisPositive :
      down
      array([ 100.,  125.,  150.,  175.,  200.,  225.,  250.,  275.,  300.,  350.,
              400.,  450.,  500.,  550.,  600.,  650.,  700.,  725.,  750.,  775.,
              800.,  825.,  850.,  875.,  900.,  925.,  950.,  975., 1000.],
            dtype=float32)
    • time1
      PandasIndex
      PandasIndex(DatetimeIndex(['1993-03-13'], dtype='datetime64[ns]', name='time1', freq=None))
    • isobaric1
      PandasIndex
      PandasIndex(Index([ 100.0,  125.0,  150.0,  175.0,  200.0,  225.0,  250.0,  275.0,  300.0,
              350.0,  400.0,  450.0,  500.0,  550.0,  600.0,  650.0,  700.0,  725.0,
              750.0,  775.0,  800.0,  825.0,  850.0,  875.0,  900.0,  925.0,  950.0,
              975.0, 1000.0],
            dtype='float32', name='isobaric1'))
InΒ [12]:
prof.plot()
Out[12]:
[<matplotlib.lines.Line2D at 0x169fd942190>]
No description has been provided for this image
InΒ [13]:
prof.plot(y="isobaric1", yincrease=False)
Out[13]:
[<matplotlib.lines.Line2D at 0x169fdb4e610>]
No description has been provided for this image
InΒ [14]:
# Plotting 2D Data
temps.sel(isobaric1=1000).plot()
Out[14]:
<matplotlib.collections.QuadMesh at 0x169fd9b8fa0>
No description has been provided for this image

Oceanic Climate SystemsΒΆ

image.png

Arithmetic operations with a single DataArray automatically apply over all array values (like NumPy). This process is called vectorization. First, let's open the monthly sea surface temperature (SST) data from the Community Earth System Model v2 (CESM2), which is a Global Climate Model.

InΒ [15]:
filepath = DATASETS.fetch("CESM2_sst_data.nc")
ds = xr.open_dataset(filepath)
ds
C:\Users\weld.c\AppData\Local\miniconda3\envs\work\lib\site-packages\xarray\conventions.py:431: SerializationWarning: variable 'tos' has multiple fill values {1e+20, 1e+20}, decoding all values to NaN.
  new_vars[k] = decode_cf_variable(
Out[15]:
<xarray.Dataset>
Dimensions:    (time: 180, d2: 2, lat: 180, lon: 360)
Coordinates:
  * time       (time) object 2000-01-15 12:00:00 ... 2014-12-15 12:00:00
  * lat        (lat) float64 -89.5 -88.5 -87.5 -86.5 ... 86.5 87.5 88.5 89.5
  * lon        (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 356.5 357.5 358.5 359.5
Dimensions without coordinates: d2
Data variables:
    time_bnds  (time, d2) object ...
    lat_bnds   (lat, d2) float64 ...
    lon_bnds   (lon, d2) float64 ...
    tos        (time, lat, lon) float32 ...
Attributes: (12/45)
    Conventions:            CF-1.7 CMIP-6.2
    activity_id:            CMIP
    branch_method:          standard
    branch_time_in_child:   674885.0
    branch_time_in_parent:  219000.0
    case_id:                972
    ...                     ...
    sub_experiment_id:      none
    table_id:               Omon
    tracking_id:            hdl:21.14100/2975ffd3-1d7b-47e3-961a-33f212ea4eb2
    variable_id:            tos
    variant_info:           CMIP6 20th century experiments (1850-2014) with C...
    variant_label:          r11i1p1f1
xarray.Dataset
    • time: 180
    • d2: 2
    • lat: 180
    • lon: 360
    • time
      (time)
      object
      2000-01-15 12:00:00 ... 2014-12-...
      axis :
      T
      bounds :
      time_bnds
      standard_name :
      time
      title :
      time
      type :
      double
      array([cftime.DatetimeNoLeap(2000, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 12, 15, 12, 0, 0, 0, has_year_zero=True)],
            dtype=object)
    • lat
      (lat)
      float64
      -89.5 -88.5 -87.5 ... 88.5 89.5
      axis :
      Y
      bounds :
      lat_bnds
      long_name :
      latitude
      standard_name :
      latitude
      units :
      degrees_north
      array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,
             -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,
             -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,
             -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,
             -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,
             -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
             -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
              -9.5,  -8.5,  -7.5,  -6.5,  -5.5,  -4.5,  -3.5,  -2.5,  -1.5,  -0.5,
               0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
              10.5,  11.5,  12.5,  13.5,  14.5,  15.5,  16.5,  17.5,  18.5,  19.5,
              20.5,  21.5,  22.5,  23.5,  24.5,  25.5,  26.5,  27.5,  28.5,  29.5,
              30.5,  31.5,  32.5,  33.5,  34.5,  35.5,  36.5,  37.5,  38.5,  39.5,
              40.5,  41.5,  42.5,  43.5,  44.5,  45.5,  46.5,  47.5,  48.5,  49.5,
              50.5,  51.5,  52.5,  53.5,  54.5,  55.5,  56.5,  57.5,  58.5,  59.5,
              60.5,  61.5,  62.5,  63.5,  64.5,  65.5,  66.5,  67.5,  68.5,  69.5,
              70.5,  71.5,  72.5,  73.5,  74.5,  75.5,  76.5,  77.5,  78.5,  79.5,
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5])
    • lon
      (lon)
      float64
      0.5 1.5 2.5 ... 357.5 358.5 359.5
      axis :
      X
      bounds :
      lon_bnds
      long_name :
      longitude
      standard_name :
      longitude
      units :
      degrees_east
      array([  0.5,   1.5,   2.5, ..., 357.5, 358.5, 359.5])
    • time_bnds
      (time, d2)
      object
      ...
      [360 values with dtype=object]
    • lat_bnds
      (lat, d2)
      float64
      ...
      long_name :
      latitude bounds
      units :
      degrees_north
      [360 values with dtype=float64]
    • lon_bnds
      (lon, d2)
      float64
      ...
      long_name :
      longitude bounds
      units :
      degrees_east
      [720 values with dtype=float64]
    • tos
      (time, lat, lon)
      float32
      ...
      cell_measures :
      area: areacello
      cell_methods :
      area: mean where sea time: mean
      comment :
      Model data on the 1x1 grid includes values in all cells for which ocean cells on the native grid cover more than 52.5 percent of the 1x1 grid cell. This 52.5 percent cutoff was chosen to produce ocean surface area on the 1x1 grid as close as possible to ocean surface area on the native grid, while not introducing fractional cell coverage.
      description :
      This may differ from "surface temperature" in regions of sea ice or floating ice shelves. For models using conservative temperature as the prognostic field, they should report the top ocean layer as surface potential temperature, which is the same as surface in situ temperature.
      frequency :
      mon
      id :
      tos
      long_name :
      Sea Surface Temperature
      mipTable :
      Omon
      out_name :
      tos
      prov :
      Omon ((isd.003))
      realm :
      ocean
      standard_name :
      sea_surface_temperature
      time :
      time
      time_label :
      time-mean
      time_title :
      Temporal mean
      title :
      Sea Surface Temperature
      type :
      real
      units :
      degC
      variable_id :
      tos
      [11664000 values with dtype=float32]
    • time
      PandasIndex
      PandasIndex(CFTimeIndex([2000-01-15 12:00:00, 2000-02-14 00:00:00, 2000-03-15 12:00:00,
                   2000-04-15 00:00:00, 2000-05-15 12:00:00, 2000-06-15 00:00:00,
                   2000-07-15 12:00:00, 2000-08-15 12:00:00, 2000-09-15 00:00:00,
                   2000-10-15 12:00:00,
                   ...
                   2014-03-15 12:00:00, 2014-04-15 00:00:00, 2014-05-15 12:00:00,
                   2014-06-15 00:00:00, 2014-07-15 12:00:00, 2014-08-15 12:00:00,
                   2014-09-15 00:00:00, 2014-10-15 12:00:00, 2014-11-15 00:00:00,
                   2014-12-15 12:00:00],
                  dtype='object', length=180, calendar='noleap', freq='None'))
    • lat
      PandasIndex
      PandasIndex(Index([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             ...
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5],
            dtype='float64', name='lat', length=180))
    • lon
      PandasIndex
      PandasIndex(Index([  0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
             ...
             350.5, 351.5, 352.5, 353.5, 354.5, 355.5, 356.5, 357.5, 358.5, 359.5],
            dtype='float64', name='lon', length=360))
  • Conventions :
    CF-1.7 CMIP-6.2
    activity_id :
    CMIP
    branch_method :
    standard
    branch_time_in_child :
    674885.0
    branch_time_in_parent :
    219000.0
    case_id :
    972
    cesm_casename :
    b.e21.BHIST.f09_g17.CMIP6-historical.011
    contact :
    cesm_cmip6@ucar.edu
    creation_date :
    2019-04-02T04:44:58Z
    data_specs_version :
    01.00.29
    experiment :
    Simulation of recent past (1850 to 2014). Impose changing conditions (consistent with observations). Should be initialised from a point early enough in the pre-industrial control run to ensure that the end of all the perturbed runs branching from the end of this historical run end before the end of the control. Only one ensemble member is requested but modelling groups are strongly encouraged to submit at least three ensemble members of their CMIP historical simulation.
    experiment_id :
    historical
    external_variables :
    areacello
    forcing_index :
    1
    frequency :
    mon
    further_info_url :
    https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.historical.none.r11i1p1f1
    grid :
    ocean data regridded from native gx1v7 displaced pole grid (384x320 latxlon) to 180x360 latxlon using conservative regridding
    grid_label :
    gr
    initialization_index :
    1
    institution :
    National Center for Atmospheric Research, Climate and Global Dynamics Laboratory, 1850 Table Mesa Drive, Boulder, CO 80305, USA
    institution_id :
    NCAR
    license :
    CMIP6 model data produced by <The National Center for Atmospheric Research> is licensed under a Creative Commons Attribution-[]ShareAlike 4.0 International License (https://creativecommons.org/licenses/). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file)[]. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.
    mip_era :
    CMIP6
    model_doi_url :
    https://doi.org/10.5065/D67H1H0V
    nominal_resolution :
    1x1 degree
    parent_activity_id :
    CMIP
    parent_experiment_id :
    piControl
    parent_mip_era :
    CMIP6
    parent_source_id :
    CESM2
    parent_time_units :
    days since 0001-01-01 00:00:00
    parent_variant_label :
    r1i1p1f1
    physics_index :
    1
    product :
    model-output
    realization_index :
    11
    realm :
    ocean
    source :
    CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); ocean: POP2 (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m); sea_ice: CICE5.1 (same grid as ocean); land: CLM5 0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); aerosol: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); atmoschem: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); landIce: CISM2.1; ocnBgchem: MARBL (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m)
    source_id :
    CESM2
    source_type :
    AOGCM BGC
    sub_experiment :
    none
    sub_experiment_id :
    none
    table_id :
    Omon
    tracking_id :
    hdl:21.14100/2975ffd3-1d7b-47e3-961a-33f212ea4eb2
    variable_id :
    tos
    variant_info :
    CMIP6 20th century experiments (1850-2014) with CAM6, interactive land (CLM5), coupled ocean (POP2) with biogeochemistry (MARBL), interactive sea ice (CICE5.1), and non-evolving land ice (CISM2.1)
    variant_label :
    r11i1p1f1
InΒ [16]:
# And look at the temeprature variable `tos`.
ds.tos
Out[16]:
<xarray.DataArray 'tos' (time: 180, lat: 180, lon: 360)>
[11664000 values with dtype=float32]
Coordinates:
  * time     (time) object 2000-01-15 12:00:00 ... 2014-12-15 12:00:00
  * lat      (lat) float64 -89.5 -88.5 -87.5 -86.5 -85.5 ... 86.5 87.5 88.5 89.5
  * lon      (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 355.5 356.5 357.5 358.5 359.5
Attributes: (12/19)
    cell_measures:  area: areacello
    cell_methods:   area: mean where sea time: mean
    comment:        Model data on the 1x1 grid includes values in all cells f...
    description:    This may differ from "surface temperature" in regions of ...
    frequency:      mon
    id:             tos
    ...             ...
    time_label:     time-mean
    time_title:     Temporal mean
    title:          Sea Surface Temperature
    type:           real
    units:          degC
    variable_id:    tos
xarray.DataArray
'tos'
  • time: 180
  • lat: 180
  • lon: 360
  • ...
    [11664000 values with dtype=float32]
    • time
      (time)
      object
      2000-01-15 12:00:00 ... 2014-12-...
      axis :
      T
      bounds :
      time_bnds
      standard_name :
      time
      title :
      time
      type :
      double
      array([cftime.DatetimeNoLeap(2000, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 12, 15, 12, 0, 0, 0, has_year_zero=True)],
            dtype=object)
    • lat
      (lat)
      float64
      -89.5 -88.5 -87.5 ... 88.5 89.5
      axis :
      Y
      bounds :
      lat_bnds
      long_name :
      latitude
      standard_name :
      latitude
      units :
      degrees_north
      array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,
             -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,
             -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,
             -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,
             -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,
             -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
             -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
              -9.5,  -8.5,  -7.5,  -6.5,  -5.5,  -4.5,  -3.5,  -2.5,  -1.5,  -0.5,
               0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
              10.5,  11.5,  12.5,  13.5,  14.5,  15.5,  16.5,  17.5,  18.5,  19.5,
              20.5,  21.5,  22.5,  23.5,  24.5,  25.5,  26.5,  27.5,  28.5,  29.5,
              30.5,  31.5,  32.5,  33.5,  34.5,  35.5,  36.5,  37.5,  38.5,  39.5,
              40.5,  41.5,  42.5,  43.5,  44.5,  45.5,  46.5,  47.5,  48.5,  49.5,
              50.5,  51.5,  52.5,  53.5,  54.5,  55.5,  56.5,  57.5,  58.5,  59.5,
              60.5,  61.5,  62.5,  63.5,  64.5,  65.5,  66.5,  67.5,  68.5,  69.5,
              70.5,  71.5,  72.5,  73.5,  74.5,  75.5,  76.5,  77.5,  78.5,  79.5,
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5])
    • lon
      (lon)
      float64
      0.5 1.5 2.5 ... 357.5 358.5 359.5
      axis :
      X
      bounds :
      lon_bnds
      long_name :
      longitude
      standard_name :
      longitude
      units :
      degrees_east
      array([  0.5,   1.5,   2.5, ..., 357.5, 358.5, 359.5])
    • time
      PandasIndex
      PandasIndex(CFTimeIndex([2000-01-15 12:00:00, 2000-02-14 00:00:00, 2000-03-15 12:00:00,
                   2000-04-15 00:00:00, 2000-05-15 12:00:00, 2000-06-15 00:00:00,
                   2000-07-15 12:00:00, 2000-08-15 12:00:00, 2000-09-15 00:00:00,
                   2000-10-15 12:00:00,
                   ...
                   2014-03-15 12:00:00, 2014-04-15 00:00:00, 2014-05-15 12:00:00,
                   2014-06-15 00:00:00, 2014-07-15 12:00:00, 2014-08-15 12:00:00,
                   2014-09-15 00:00:00, 2014-10-15 12:00:00, 2014-11-15 00:00:00,
                   2014-12-15 12:00:00],
                  dtype='object', length=180, calendar='noleap', freq='None'))
    • lat
      PandasIndex
      PandasIndex(Index([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             ...
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5],
            dtype='float64', name='lat', length=180))
    • lon
      PandasIndex
      PandasIndex(Index([  0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
             ...
             350.5, 351.5, 352.5, 353.5, 354.5, 355.5, 356.5, 357.5, 358.5, 359.5],
            dtype='float64', name='lon', length=360))
  • cell_measures :
    area: areacello
    cell_methods :
    area: mean where sea time: mean
    comment :
    Model data on the 1x1 grid includes values in all cells for which ocean cells on the native grid cover more than 52.5 percent of the 1x1 grid cell. This 52.5 percent cutoff was chosen to produce ocean surface area on the 1x1 grid as close as possible to ocean surface area on the native grid, while not introducing fractional cell coverage.
    description :
    This may differ from "surface temperature" in regions of sea ice or floating ice shelves. For models using conservative temperature as the prognostic field, they should report the top ocean layer as surface potential temperature, which is the same as surface in situ temperature.
    frequency :
    mon
    id :
    tos
    long_name :
    Sea Surface Temperature
    mipTable :
    Omon
    out_name :
    tos
    prov :
    Omon ((isd.003))
    realm :
    ocean
    standard_name :
    sea_surface_temperature
    time :
    time
    time_label :
    time-mean
    time_title :
    Temporal mean
    title :
    Sea Surface Temperature
    type :
    real
    units :
    degC
    variable_id :
    tos
Aggregation MethodsΒΆ

A very common step during data analysis is to summarize the data in question by computing aggregations like sum(), mean(), median(), min(), max() in which reduced data provide insight into the nature of the large dataset. For example, in the introductory video for this tutorial, we saw maps of the mean annual sea surface temperature and sea surface density.

The following table summarizes some other built-in xarray aggregations:

Aggregation Description
count() Total number of items
mean(), median() Mean and median
min(), max() Minimum and maximum
std(), var() Standard deviation and variance
prod() Compute product of elements
sum() Compute sum of elements
argmin(), argmax() Find index of minimum and maximum value

Let's explore some of these aggregation methods.

InΒ [17]:
# Calculate the mean in time for all locations (i.e. the global mean annual SST), specify the time dimension as the dimension along which the mean should be calculated:
ds.tos.mean(dim="time").plot(size=7, vmin=-2, vmax=32, cmap="coolwarm")
Out[17]:
<matplotlib.collections.QuadMesh at 0x169fdb81b20>
No description has been provided for this image

You may notice that there are a lot of NaN values in the DataArray for tos. NaN isn’t a bad thing and it just means there isn’t data for those coordinates. In this case, there's no tos data for areas with land since this dataset only contains SST values.

InΒ [18]:
ds.tos.mean(dim="lon").plot(size=7, vmin=-2, vmax=32, cmap="coolwarm", x='time')
Out[18]:
<matplotlib.collections.QuadMesh at 0x169821916a0>
No description has been provided for this image
InΒ [19]:
ds.tos.mean(dim="lat").plot(size=7, vmin=-2, vmax=32, cmap="coolwarm", x='time')
Out[19]:
<matplotlib.collections.QuadMesh at 0x1698228fe20>
No description has been provided for this image

Terrestrial Temperature & RainfallΒΆ

image.png

We are going to use groupby to remove the seasonal cycle ("climatology") from our dataset, which will allow us to better observe long-term trends in the data. See the xarray groupby user guide for more examples of what groupby can take as an input.

InΒ [20]:
# Let's use the same data that we used in the previous tutorial (monthly SST data from CESM2):
ds
Out[20]:
<xarray.Dataset>
Dimensions:    (time: 180, d2: 2, lat: 180, lon: 360)
Coordinates:
  * time       (time) object 2000-01-15 12:00:00 ... 2014-12-15 12:00:00
  * lat        (lat) float64 -89.5 -88.5 -87.5 -86.5 ... 86.5 87.5 88.5 89.5
  * lon        (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 356.5 357.5 358.5 359.5
Dimensions without coordinates: d2
Data variables:
    time_bnds  (time, d2) object ...
    lat_bnds   (lat, d2) float64 ...
    lon_bnds   (lon, d2) float64 ...
    tos        (time, lat, lon) float32 nan nan nan nan ... -1.746 -1.746 -1.746
Attributes: (12/45)
    Conventions:            CF-1.7 CMIP-6.2
    activity_id:            CMIP
    branch_method:          standard
    branch_time_in_child:   674885.0
    branch_time_in_parent:  219000.0
    case_id:                972
    ...                     ...
    sub_experiment_id:      none
    table_id:               Omon
    tracking_id:            hdl:21.14100/2975ffd3-1d7b-47e3-961a-33f212ea4eb2
    variable_id:            tos
    variant_info:           CMIP6 20th century experiments (1850-2014) with C...
    variant_label:          r11i1p1f1
xarray.Dataset
    • time: 180
    • d2: 2
    • lat: 180
    • lon: 360
    • time
      (time)
      object
      2000-01-15 12:00:00 ... 2014-12-...
      axis :
      T
      bounds :
      time_bnds
      standard_name :
      time
      title :
      time
      type :
      double
      array([cftime.DatetimeNoLeap(2000, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 12, 15, 12, 0, 0, 0, has_year_zero=True)],
            dtype=object)
    • lat
      (lat)
      float64
      -89.5 -88.5 -87.5 ... 88.5 89.5
      axis :
      Y
      bounds :
      lat_bnds
      long_name :
      latitude
      standard_name :
      latitude
      units :
      degrees_north
      array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,
             -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,
             -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,
             -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,
             -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,
             -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
             -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
              -9.5,  -8.5,  -7.5,  -6.5,  -5.5,  -4.5,  -3.5,  -2.5,  -1.5,  -0.5,
               0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
              10.5,  11.5,  12.5,  13.5,  14.5,  15.5,  16.5,  17.5,  18.5,  19.5,
              20.5,  21.5,  22.5,  23.5,  24.5,  25.5,  26.5,  27.5,  28.5,  29.5,
              30.5,  31.5,  32.5,  33.5,  34.5,  35.5,  36.5,  37.5,  38.5,  39.5,
              40.5,  41.5,  42.5,  43.5,  44.5,  45.5,  46.5,  47.5,  48.5,  49.5,
              50.5,  51.5,  52.5,  53.5,  54.5,  55.5,  56.5,  57.5,  58.5,  59.5,
              60.5,  61.5,  62.5,  63.5,  64.5,  65.5,  66.5,  67.5,  68.5,  69.5,
              70.5,  71.5,  72.5,  73.5,  74.5,  75.5,  76.5,  77.5,  78.5,  79.5,
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5])
    • lon
      (lon)
      float64
      0.5 1.5 2.5 ... 357.5 358.5 359.5
      axis :
      X
      bounds :
      lon_bnds
      long_name :
      longitude
      standard_name :
      longitude
      units :
      degrees_east
      array([  0.5,   1.5,   2.5, ..., 357.5, 358.5, 359.5])
    • time_bnds
      (time, d2)
      object
      ...
      [360 values with dtype=object]
    • lat_bnds
      (lat, d2)
      float64
      ...
      long_name :
      latitude bounds
      units :
      degrees_north
      [360 values with dtype=float64]
    • lon_bnds
      (lon, d2)
      float64
      ...
      long_name :
      longitude bounds
      units :
      degrees_east
      [720 values with dtype=float64]
    • tos
      (time, lat, lon)
      float32
      nan nan nan ... -1.746 -1.746
      cell_measures :
      area: areacello
      cell_methods :
      area: mean where sea time: mean
      comment :
      Model data on the 1x1 grid includes values in all cells for which ocean cells on the native grid cover more than 52.5 percent of the 1x1 grid cell. This 52.5 percent cutoff was chosen to produce ocean surface area on the 1x1 grid as close as possible to ocean surface area on the native grid, while not introducing fractional cell coverage.
      description :
      This may differ from "surface temperature" in regions of sea ice or floating ice shelves. For models using conservative temperature as the prognostic field, they should report the top ocean layer as surface potential temperature, which is the same as surface in situ temperature.
      frequency :
      mon
      id :
      tos
      long_name :
      Sea Surface Temperature
      mipTable :
      Omon
      out_name :
      tos
      prov :
      Omon ((isd.003))
      realm :
      ocean
      standard_name :
      sea_surface_temperature
      time :
      time
      time_label :
      time-mean
      time_title :
      Temporal mean
      title :
      Sea Surface Temperature
      type :
      real
      units :
      degC
      variable_id :
      tos
      array([[[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.789945, -1.789865, ..., -1.790069, -1.790012],
              [-1.785529, -1.78547 , ..., -1.785646, -1.78559 ]],
      
             [[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.794789, -1.794727, ..., -1.794875, -1.794837],
              [-1.79065 , -1.790609, ..., -1.790736, -1.790694]],
      
             ...,
      
             [[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.737043, -1.737051, ..., -1.736985, -1.73702 ],
              [-1.732279, -1.732275, ..., -1.732309, -1.732295]],
      
             [[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.750638, -1.750658, ..., -1.750561, -1.750605],
              [-1.74627 , -1.746267, ..., -1.746299, -1.746285]]], dtype=float32)
    • time
      PandasIndex
      PandasIndex(CFTimeIndex([2000-01-15 12:00:00, 2000-02-14 00:00:00, 2000-03-15 12:00:00,
                   2000-04-15 00:00:00, 2000-05-15 12:00:00, 2000-06-15 00:00:00,
                   2000-07-15 12:00:00, 2000-08-15 12:00:00, 2000-09-15 00:00:00,
                   2000-10-15 12:00:00,
                   ...
                   2014-03-15 12:00:00, 2014-04-15 00:00:00, 2014-05-15 12:00:00,
                   2014-06-15 00:00:00, 2014-07-15 12:00:00, 2014-08-15 12:00:00,
                   2014-09-15 00:00:00, 2014-10-15 12:00:00, 2014-11-15 00:00:00,
                   2014-12-15 12:00:00],
                  dtype='object', length=180, calendar='noleap', freq='None'))
    • lat
      PandasIndex
      PandasIndex(Index([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             ...
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5],
            dtype='float64', name='lat', length=180))
    • lon
      PandasIndex
      PandasIndex(Index([  0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
             ...
             350.5, 351.5, 352.5, 353.5, 354.5, 355.5, 356.5, 357.5, 358.5, 359.5],
            dtype='float64', name='lon', length=360))
  • Conventions :
    CF-1.7 CMIP-6.2
    activity_id :
    CMIP
    branch_method :
    standard
    branch_time_in_child :
    674885.0
    branch_time_in_parent :
    219000.0
    case_id :
    972
    cesm_casename :
    b.e21.BHIST.f09_g17.CMIP6-historical.011
    contact :
    cesm_cmip6@ucar.edu
    creation_date :
    2019-04-02T04:44:58Z
    data_specs_version :
    01.00.29
    experiment :
    Simulation of recent past (1850 to 2014). Impose changing conditions (consistent with observations). Should be initialised from a point early enough in the pre-industrial control run to ensure that the end of all the perturbed runs branching from the end of this historical run end before the end of the control. Only one ensemble member is requested but modelling groups are strongly encouraged to submit at least three ensemble members of their CMIP historical simulation.
    experiment_id :
    historical
    external_variables :
    areacello
    forcing_index :
    1
    frequency :
    mon
    further_info_url :
    https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.historical.none.r11i1p1f1
    grid :
    ocean data regridded from native gx1v7 displaced pole grid (384x320 latxlon) to 180x360 latxlon using conservative regridding
    grid_label :
    gr
    initialization_index :
    1
    institution :
    National Center for Atmospheric Research, Climate and Global Dynamics Laboratory, 1850 Table Mesa Drive, Boulder, CO 80305, USA
    institution_id :
    NCAR
    license :
    CMIP6 model data produced by <The National Center for Atmospheric Research> is licensed under a Creative Commons Attribution-[]ShareAlike 4.0 International License (https://creativecommons.org/licenses/). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file)[]. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.
    mip_era :
    CMIP6
    model_doi_url :
    https://doi.org/10.5065/D67H1H0V
    nominal_resolution :
    1x1 degree
    parent_activity_id :
    CMIP
    parent_experiment_id :
    piControl
    parent_mip_era :
    CMIP6
    parent_source_id :
    CESM2
    parent_time_units :
    days since 0001-01-01 00:00:00
    parent_variant_label :
    r1i1p1f1
    physics_index :
    1
    product :
    model-output
    realization_index :
    11
    realm :
    ocean
    source :
    CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); ocean: POP2 (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m); sea_ice: CICE5.1 (same grid as ocean); land: CLM5 0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); aerosol: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); atmoschem: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); landIce: CISM2.1; ocnBgchem: MARBL (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m)
    source_id :
    CESM2
    source_type :
    AOGCM BGC
    sub_experiment :
    none
    sub_experiment_id :
    none
    table_id :
    Omon
    tracking_id :
    hdl:21.14100/2975ffd3-1d7b-47e3-961a-33f212ea4eb2
    variable_id :
    tos
    variant_info :
    CMIP6 20th century experiments (1850-2014) with CAM6, interactive land (CLM5), coupled ocean (POP2) with biogeochemistry (MARBL), interactive sea ice (CICE5.1), and non-evolving land ice (CISM2.1)
    variant_label :
    r11i1p1f1

Then, let's select a gridpoint closest to a specified lat-lon (in this case let's select 50ΒΊN, 310ΒΊE), and plot a time series of SST at that point. The annual cycle will be quite pronounced. Note that we are using the nearest method (see Tutorial 2 for a refresher) to find the points in our datasets closest to the lat-lon values we specify. What this returns may not match these inputs exactly.

InΒ [21]:
ds.tos.sel(lon=310, lat=50, method="nearest").plot()  # time range is 2000-01-15 to 2014-12-15
Out[21]:
[<matplotlib.lines.Line2D at 0x16982a75760>]
No description has been provided for this image

Compute the ClimatologyΒΆ

Let's calculate the climatology at every point in the dataset. To do so, we will use aggregation and will calculate the mean SST for each month:

InΒ [22]:
tos_clim = ds.tos.groupby("time.month").mean()
tos_clim.sel(lon=310, lat=50, method="nearest").plot()
Out[22]:
[<matplotlib.lines.Line2D at 0x169fc76cd60>]
No description has been provided for this image

We can now add a spatial dimension to this plot and look at the zonal mean climatology (the monthly mean SST at different latitudes):

InΒ [23]:
tos_clim.mean(dim="lon").transpose().plot.contourf(levels=12, cmap="turbo")
Out[23]:
<matplotlib.contour.QuadContourSet at 0x1698218a1f0>
No description has been provided for this image

This gives us helpful information about the mean SST for each month, but it's difficult to asses the range of monthly temperatures throughout the year using this plot. To better represent the range of SST, we can calculate and plot the difference between January and July climatologies:

InΒ [24]:
(tos_clim.sel(month=1) - tos_clim.sel(month=7)).plot(size=6, robust=True)
Out[24]:
<matplotlib.collections.QuadMesh at 0x16982cb3340>
No description has been provided for this image
InΒ [25]:
(tos_clim.sel(month=7) - tos_clim.sel(month=1)).plot(size=6, robust=True)
Out[25]:
<matplotlib.collections.QuadMesh at 0x169830981f0>
No description has been provided for this image

Orbital CyclesΒΆ

image.png

Compute AnomalyΒΆ

Let's use the same data that we used in the previous tutorial (monthly SST data from CESM2):

InΒ [26]:
ds
Out[26]:
<xarray.Dataset>
Dimensions:    (time: 180, d2: 2, lat: 180, lon: 360)
Coordinates:
  * time       (time) object 2000-01-15 12:00:00 ... 2014-12-15 12:00:00
  * lat        (lat) float64 -89.5 -88.5 -87.5 -86.5 ... 86.5 87.5 88.5 89.5
  * lon        (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 356.5 357.5 358.5 359.5
Dimensions without coordinates: d2
Data variables:
    time_bnds  (time, d2) object ...
    lat_bnds   (lat, d2) float64 ...
    lon_bnds   (lon, d2) float64 ...
    tos        (time, lat, lon) float32 nan nan nan nan ... -1.746 -1.746 -1.746
Attributes: (12/45)
    Conventions:            CF-1.7 CMIP-6.2
    activity_id:            CMIP
    branch_method:          standard
    branch_time_in_child:   674885.0
    branch_time_in_parent:  219000.0
    case_id:                972
    ...                     ...
    sub_experiment_id:      none
    table_id:               Omon
    tracking_id:            hdl:21.14100/2975ffd3-1d7b-47e3-961a-33f212ea4eb2
    variable_id:            tos
    variant_info:           CMIP6 20th century experiments (1850-2014) with C...
    variant_label:          r11i1p1f1
xarray.Dataset
    • time: 180
    • d2: 2
    • lat: 180
    • lon: 360
    • time
      (time)
      object
      2000-01-15 12:00:00 ... 2014-12-...
      axis :
      T
      bounds :
      time_bnds
      standard_name :
      time
      title :
      time
      type :
      double
      array([cftime.DatetimeNoLeap(2000, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 12, 15, 12, 0, 0, 0, has_year_zero=True)],
            dtype=object)
    • lat
      (lat)
      float64
      -89.5 -88.5 -87.5 ... 88.5 89.5
      axis :
      Y
      bounds :
      lat_bnds
      long_name :
      latitude
      standard_name :
      latitude
      units :
      degrees_north
      array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,
             -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,
             -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,
             -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,
             -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,
             -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
             -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
              -9.5,  -8.5,  -7.5,  -6.5,  -5.5,  -4.5,  -3.5,  -2.5,  -1.5,  -0.5,
               0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
              10.5,  11.5,  12.5,  13.5,  14.5,  15.5,  16.5,  17.5,  18.5,  19.5,
              20.5,  21.5,  22.5,  23.5,  24.5,  25.5,  26.5,  27.5,  28.5,  29.5,
              30.5,  31.5,  32.5,  33.5,  34.5,  35.5,  36.5,  37.5,  38.5,  39.5,
              40.5,  41.5,  42.5,  43.5,  44.5,  45.5,  46.5,  47.5,  48.5,  49.5,
              50.5,  51.5,  52.5,  53.5,  54.5,  55.5,  56.5,  57.5,  58.5,  59.5,
              60.5,  61.5,  62.5,  63.5,  64.5,  65.5,  66.5,  67.5,  68.5,  69.5,
              70.5,  71.5,  72.5,  73.5,  74.5,  75.5,  76.5,  77.5,  78.5,  79.5,
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5])
    • lon
      (lon)
      float64
      0.5 1.5 2.5 ... 357.5 358.5 359.5
      axis :
      X
      bounds :
      lon_bnds
      long_name :
      longitude
      standard_name :
      longitude
      units :
      degrees_east
      array([  0.5,   1.5,   2.5, ..., 357.5, 358.5, 359.5])
    • time_bnds
      (time, d2)
      object
      ...
      [360 values with dtype=object]
    • lat_bnds
      (lat, d2)
      float64
      ...
      long_name :
      latitude bounds
      units :
      degrees_north
      [360 values with dtype=float64]
    • lon_bnds
      (lon, d2)
      float64
      ...
      long_name :
      longitude bounds
      units :
      degrees_east
      [720 values with dtype=float64]
    • tos
      (time, lat, lon)
      float32
      nan nan nan ... -1.746 -1.746
      cell_measures :
      area: areacello
      cell_methods :
      area: mean where sea time: mean
      comment :
      Model data on the 1x1 grid includes values in all cells for which ocean cells on the native grid cover more than 52.5 percent of the 1x1 grid cell. This 52.5 percent cutoff was chosen to produce ocean surface area on the 1x1 grid as close as possible to ocean surface area on the native grid, while not introducing fractional cell coverage.
      description :
      This may differ from "surface temperature" in regions of sea ice or floating ice shelves. For models using conservative temperature as the prognostic field, they should report the top ocean layer as surface potential temperature, which is the same as surface in situ temperature.
      frequency :
      mon
      id :
      tos
      long_name :
      Sea Surface Temperature
      mipTable :
      Omon
      out_name :
      tos
      prov :
      Omon ((isd.003))
      realm :
      ocean
      standard_name :
      sea_surface_temperature
      time :
      time
      time_label :
      time-mean
      time_title :
      Temporal mean
      title :
      Sea Surface Temperature
      type :
      real
      units :
      degC
      variable_id :
      tos
      array([[[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.789945, -1.789865, ..., -1.790069, -1.790012],
              [-1.785529, -1.78547 , ..., -1.785646, -1.78559 ]],
      
             [[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.794789, -1.794727, ..., -1.794875, -1.794837],
              [-1.79065 , -1.790609, ..., -1.790736, -1.790694]],
      
             ...,
      
             [[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.737043, -1.737051, ..., -1.736985, -1.73702 ],
              [-1.732279, -1.732275, ..., -1.732309, -1.732295]],
      
             [[      nan,       nan, ...,       nan,       nan],
              [      nan,       nan, ...,       nan,       nan],
              ...,
              [-1.750638, -1.750658, ..., -1.750561, -1.750605],
              [-1.74627 , -1.746267, ..., -1.746299, -1.746285]]], dtype=float32)
    • time
      PandasIndex
      PandasIndex(CFTimeIndex([2000-01-15 12:00:00, 2000-02-14 00:00:00, 2000-03-15 12:00:00,
                   2000-04-15 00:00:00, 2000-05-15 12:00:00, 2000-06-15 00:00:00,
                   2000-07-15 12:00:00, 2000-08-15 12:00:00, 2000-09-15 00:00:00,
                   2000-10-15 12:00:00,
                   ...
                   2014-03-15 12:00:00, 2014-04-15 00:00:00, 2014-05-15 12:00:00,
                   2014-06-15 00:00:00, 2014-07-15 12:00:00, 2014-08-15 12:00:00,
                   2014-09-15 00:00:00, 2014-10-15 12:00:00, 2014-11-15 00:00:00,
                   2014-12-15 12:00:00],
                  dtype='object', length=180, calendar='noleap', freq='None'))
    • lat
      PandasIndex
      PandasIndex(Index([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             ...
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5],
            dtype='float64', name='lat', length=180))
    • lon
      PandasIndex
      PandasIndex(Index([  0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
             ...
             350.5, 351.5, 352.5, 353.5, 354.5, 355.5, 356.5, 357.5, 358.5, 359.5],
            dtype='float64', name='lon', length=360))
  • Conventions :
    CF-1.7 CMIP-6.2
    activity_id :
    CMIP
    branch_method :
    standard
    branch_time_in_child :
    674885.0
    branch_time_in_parent :
    219000.0
    case_id :
    972
    cesm_casename :
    b.e21.BHIST.f09_g17.CMIP6-historical.011
    contact :
    cesm_cmip6@ucar.edu
    creation_date :
    2019-04-02T04:44:58Z
    data_specs_version :
    01.00.29
    experiment :
    Simulation of recent past (1850 to 2014). Impose changing conditions (consistent with observations). Should be initialised from a point early enough in the pre-industrial control run to ensure that the end of all the perturbed runs branching from the end of this historical run end before the end of the control. Only one ensemble member is requested but modelling groups are strongly encouraged to submit at least three ensemble members of their CMIP historical simulation.
    experiment_id :
    historical
    external_variables :
    areacello
    forcing_index :
    1
    frequency :
    mon
    further_info_url :
    https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.historical.none.r11i1p1f1
    grid :
    ocean data regridded from native gx1v7 displaced pole grid (384x320 latxlon) to 180x360 latxlon using conservative regridding
    grid_label :
    gr
    initialization_index :
    1
    institution :
    National Center for Atmospheric Research, Climate and Global Dynamics Laboratory, 1850 Table Mesa Drive, Boulder, CO 80305, USA
    institution_id :
    NCAR
    license :
    CMIP6 model data produced by <The National Center for Atmospheric Research> is licensed under a Creative Commons Attribution-[]ShareAlike 4.0 International License (https://creativecommons.org/licenses/). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file)[]. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.
    mip_era :
    CMIP6
    model_doi_url :
    https://doi.org/10.5065/D67H1H0V
    nominal_resolution :
    1x1 degree
    parent_activity_id :
    CMIP
    parent_experiment_id :
    piControl
    parent_mip_era :
    CMIP6
    parent_source_id :
    CESM2
    parent_time_units :
    days since 0001-01-01 00:00:00
    parent_variant_label :
    r1i1p1f1
    physics_index :
    1
    product :
    model-output
    realization_index :
    11
    realm :
    ocean
    source :
    CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); ocean: POP2 (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m); sea_ice: CICE5.1 (same grid as ocean); land: CLM5 0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); aerosol: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); atmoschem: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); landIce: CISM2.1; ocnBgchem: MARBL (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m)
    source_id :
    CESM2
    source_type :
    AOGCM BGC
    sub_experiment :
    none
    sub_experiment_id :
    none
    table_id :
    Omon
    tracking_id :
    hdl:21.14100/2975ffd3-1d7b-47e3-961a-33f212ea4eb2
    variable_id :
    tos
    variant_info :
    CMIP6 20th century experiments (1850-2014) with CAM6, interactive land (CLM5), coupled ocean (POP2) with biogeochemistry (MARBL), interactive sea ice (CICE5.1), and non-evolving land ice (CISM2.1)
    variant_label :
    r11i1p1f1

We'll compute the climatology using xarray's groupby operation to split the SST data by month. Then, we'll remove this climatology from our original data to find the anomaly:

InΒ [27]:
# group all data by month
gb = ds.tos.groupby("time.month")

# take the mean over time to get monthly averages
tos_clim = gb.mean(dim="time")

# subtract this mean from all data of the same month
tos_anom = gb - tos_clim
tos_anom
Out[27]:
<xarray.DataArray 'tos' (time: 180, lat: 180, lon: 360)>
array([[[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        ...,
        [-0.01402271, -0.01401687, -0.01401365, ..., -0.01406252,
         -0.01404917, -0.01403356],
        [-0.01544118, -0.01544476, -0.01545036, ..., -0.0154475 ,
         -0.01544321, -0.01544082],
        [-0.01638114, -0.01639009, -0.01639998, ..., -0.01635301,
         -0.01636147, -0.01637137]],

       [[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
...
        [ 0.01727939,  0.01713431,  0.01698041, ...,  0.0176847 ,
          0.01755834,  0.01742125],
        [ 0.0173862 ,  0.0172919 ,  0.01719594, ...,  0.01766813,
          0.01757395,  0.01748013],
        [ 0.01693714,  0.01687253,  0.01680517, ...,  0.01709175,
          0.0170424 ,  0.01699162]],

       [[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        ...,
        [ 0.01506364,  0.01491845,  0.01476014, ...,  0.01545238,
          0.0153321 ,  0.01520228],
        [ 0.0142287 ,  0.01412642,  0.01402068, ...,  0.0145216 ,
          0.01442552,  0.01432824],
        [ 0.01320827,  0.01314461,  0.01307774, ...,  0.0133611 ,
          0.0133127 ,  0.01326215]]], dtype=float32)
Coordinates:
  * time     (time) object 2000-01-15 12:00:00 ... 2014-12-15 12:00:00
  * lat      (lat) float64 -89.5 -88.5 -87.5 -86.5 -85.5 ... 86.5 87.5 88.5 89.5
  * lon      (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 355.5 356.5 357.5 358.5 359.5
    month    (time) int64 1 2 3 4 5 6 7 8 9 10 11 ... 2 3 4 5 6 7 8 9 10 11 12
xarray.DataArray
'tos'
  • time: 180
  • lat: 180
  • lon: 360
  • nan nan nan nan nan nan ... 0.01345 0.01341 0.01336 0.01331 0.01326
    array([[[        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            [        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            [        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            ...,
            [-0.01402271, -0.01401687, -0.01401365, ..., -0.01406252,
             -0.01404917, -0.01403356],
            [-0.01544118, -0.01544476, -0.01545036, ..., -0.0154475 ,
             -0.01544321, -0.01544082],
            [-0.01638114, -0.01639009, -0.01639998, ..., -0.01635301,
             -0.01636147, -0.01637137]],
    
           [[        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            [        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            [        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
    ...
            [ 0.01727939,  0.01713431,  0.01698041, ...,  0.0176847 ,
              0.01755834,  0.01742125],
            [ 0.0173862 ,  0.0172919 ,  0.01719594, ...,  0.01766813,
              0.01757395,  0.01748013],
            [ 0.01693714,  0.01687253,  0.01680517, ...,  0.01709175,
              0.0170424 ,  0.01699162]],
    
           [[        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            [        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            [        nan,         nan,         nan, ...,         nan,
                     nan,         nan],
            ...,
            [ 0.01506364,  0.01491845,  0.01476014, ...,  0.01545238,
              0.0153321 ,  0.01520228],
            [ 0.0142287 ,  0.01412642,  0.01402068, ...,  0.0145216 ,
              0.01442552,  0.01432824],
            [ 0.01320827,  0.01314461,  0.01307774, ...,  0.0133611 ,
              0.0133127 ,  0.01326215]]], dtype=float32)
    • time
      (time)
      object
      2000-01-15 12:00:00 ... 2014-12-...
      axis :
      T
      bounds :
      time_bnds
      standard_name :
      time
      title :
      time
      type :
      double
      array([cftime.DatetimeNoLeap(2000, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2000, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2001, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2002, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2003, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2004, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2005, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2006, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2007, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2008, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2009, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2010, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2011, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2012, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2013, 12, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 1, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 2, 14, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 3, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 4, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 5, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 6, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 7, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 8, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 9, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 10, 15, 12, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 11, 15, 0, 0, 0, 0, has_year_zero=True),
             cftime.DatetimeNoLeap(2014, 12, 15, 12, 0, 0, 0, has_year_zero=True)],
            dtype=object)
    • lat
      (lat)
      float64
      -89.5 -88.5 -87.5 ... 88.5 89.5
      axis :
      Y
      bounds :
      lat_bnds
      long_name :
      latitude
      standard_name :
      latitude
      units :
      degrees_north
      array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,
             -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,
             -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,
             -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,
             -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,
             -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
             -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
              -9.5,  -8.5,  -7.5,  -6.5,  -5.5,  -4.5,  -3.5,  -2.5,  -1.5,  -0.5,
               0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
              10.5,  11.5,  12.5,  13.5,  14.5,  15.5,  16.5,  17.5,  18.5,  19.5,
              20.5,  21.5,  22.5,  23.5,  24.5,  25.5,  26.5,  27.5,  28.5,  29.5,
              30.5,  31.5,  32.5,  33.5,  34.5,  35.5,  36.5,  37.5,  38.5,  39.5,
              40.5,  41.5,  42.5,  43.5,  44.5,  45.5,  46.5,  47.5,  48.5,  49.5,
              50.5,  51.5,  52.5,  53.5,  54.5,  55.5,  56.5,  57.5,  58.5,  59.5,
              60.5,  61.5,  62.5,  63.5,  64.5,  65.5,  66.5,  67.5,  68.5,  69.5,
              70.5,  71.5,  72.5,  73.5,  74.5,  75.5,  76.5,  77.5,  78.5,  79.5,
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5])
    • lon
      (lon)
      float64
      0.5 1.5 2.5 ... 357.5 358.5 359.5
      axis :
      X
      bounds :
      lon_bnds
      long_name :
      longitude
      standard_name :
      longitude
      units :
      degrees_east
      array([  0.5,   1.5,   2.5, ..., 357.5, 358.5, 359.5])
    • month
      (time)
      int64
      1 2 3 4 5 6 7 ... 6 7 8 9 10 11 12
      array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,
              7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
              1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,
              7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
              1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,
              7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
              1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,
              7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
              1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,
              7,  8,  9, 10, 11, 12,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12],
            dtype=int64)
    • time
      PandasIndex
      PandasIndex(CFTimeIndex([2000-01-15 12:00:00, 2000-02-14 00:00:00, 2000-03-15 12:00:00,
                   2000-04-15 00:00:00, 2000-05-15 12:00:00, 2000-06-15 00:00:00,
                   2000-07-15 12:00:00, 2000-08-15 12:00:00, 2000-09-15 00:00:00,
                   2000-10-15 12:00:00,
                   ...
                   2014-03-15 12:00:00, 2014-04-15 00:00:00, 2014-05-15 12:00:00,
                   2014-06-15 00:00:00, 2014-07-15 12:00:00, 2014-08-15 12:00:00,
                   2014-09-15 00:00:00, 2014-10-15 12:00:00, 2014-11-15 00:00:00,
                   2014-12-15 12:00:00],
                  dtype='object', length=180, calendar='noleap', freq='None'))
    • lat
      PandasIndex
      PandasIndex(Index([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             ...
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5],
            dtype='float64', name='lat', length=180))
    • lon
      PandasIndex
      PandasIndex(Index([  0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
             ...
             350.5, 351.5, 352.5, 353.5, 354.5, 355.5, 356.5, 357.5, 358.5, 359.5],
            dtype='float64', name='lon', length=360))
InΒ [28]:
# Let's try plotting the anomaly from a specific location:
plt.ylabel("tos anomaly")
tos_anom.sel(lon=310, lat=50, method="nearest").plot()
Out[28]:
[<matplotlib.lines.Line2D at 0x169844016a0>]
No description has been provided for this image

Next, let's compute and visualize the mean global anomaly over time. We need to specify both lat and lon dimensions in the dim argument to mean():

InΒ [29]:
unweighted_mean_global_anom = tos_anom.mean(dim=["lat", "lon"])
unweighted_mean_global_anom.plot()
plt.ylabel("global mean tos anomaly")
Out[29]:
Text(0, 0.5, 'global mean tos anomaly')
No description has been provided for this image

Notice that we called our variable unweighted_mean_global_anom. Next, we are going to compute the weighted_mean_global_anom. Why do we need to weight our data? Grid cells with the same range of degrees latitude and longitude are not necessarily same size. Specifically, grid cells closer to the equator are much larger than those near the poles, as seen in the figure below (Djexplo, 2011, CC-BY).

area by latitude

Therefore, an operation which combines grid cells of different size is not scientifically valid unless each cell is weighted by the size of the grid cell. Xarray has a convenient .weighted() method to accomplish this.

InΒ [30]:
# Let's first load the grid cell area data from another CESM2 dataset that contains the weights for the grid cells:
filepath2 = DATASETS.fetch("CESM2_grid_variables.nc")
areacello = xr.open_dataset(filepath2).areacello
areacello
Out[30]:
<xarray.DataArray 'areacello' (lat: 180, lon: 360)>
[64800 values with dtype=float64]
Coordinates:
  * lat      (lat) float64 -89.5 -88.5 -87.5 -86.5 -85.5 ... 86.5 87.5 88.5 89.5
  * lon      (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 355.5 356.5 357.5 358.5 359.5
Attributes: (12/17)
    cell_methods:   area: sum
    comment:        TAREA
    description:    Cell areas for any grid used to report ocean variables an...
    frequency:      fx
    id:             areacello
    long_name:      Grid-Cell Area for Ocean Variables
    ...             ...
    time_label:     None
    time_title:     No temporal dimensions ... fixed field
    title:          Grid-Cell Area for Ocean Variables
    type:           real
    units:          m2
    variable_id:    areacello
xarray.DataArray
'areacello'
  • lat: 180
  • lon: 360
  • ...
    [64800 values with dtype=float64]
    • lat
      (lat)
      float64
      -89.5 -88.5 -87.5 ... 88.5 89.5
      axis :
      Y
      bounds :
      lat_bnds
      long_name :
      latitude
      standard_name :
      latitude
      units :
      degrees_north
      array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,
             -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,
             -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,
             -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,
             -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,
             -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
             -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
              -9.5,  -8.5,  -7.5,  -6.5,  -5.5,  -4.5,  -3.5,  -2.5,  -1.5,  -0.5,
               0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
              10.5,  11.5,  12.5,  13.5,  14.5,  15.5,  16.5,  17.5,  18.5,  19.5,
              20.5,  21.5,  22.5,  23.5,  24.5,  25.5,  26.5,  27.5,  28.5,  29.5,
              30.5,  31.5,  32.5,  33.5,  34.5,  35.5,  36.5,  37.5,  38.5,  39.5,
              40.5,  41.5,  42.5,  43.5,  44.5,  45.5,  46.5,  47.5,  48.5,  49.5,
              50.5,  51.5,  52.5,  53.5,  54.5,  55.5,  56.5,  57.5,  58.5,  59.5,
              60.5,  61.5,  62.5,  63.5,  64.5,  65.5,  66.5,  67.5,  68.5,  69.5,
              70.5,  71.5,  72.5,  73.5,  74.5,  75.5,  76.5,  77.5,  78.5,  79.5,
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5])
    • lon
      (lon)
      float64
      0.5 1.5 2.5 ... 357.5 358.5 359.5
      axis :
      X
      bounds :
      lon_bnds
      long_name :
      longitude
      standard_name :
      longitude
      units :
      degrees_east
      array([  0.5,   1.5,   2.5, ..., 357.5, 358.5, 359.5])
    • lat
      PandasIndex
      PandasIndex(Index([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,
             ...
              80.5,  81.5,  82.5,  83.5,  84.5,  85.5,  86.5,  87.5,  88.5,  89.5],
            dtype='float64', name='lat', length=180))
    • lon
      PandasIndex
      PandasIndex(Index([  0.5,   1.5,   2.5,   3.5,   4.5,   5.5,   6.5,   7.5,   8.5,   9.5,
             ...
             350.5, 351.5, 352.5, 353.5, 354.5, 355.5, 356.5, 357.5, 358.5, 359.5],
            dtype='float64', name='lon', length=360))
  • cell_methods :
    area: sum
    comment :
    TAREA
    description :
    Cell areas for any grid used to report ocean variables and variables which are requested as used on the model ocean grid (e.g. hfsso, which is a downward heat flux from the atmosphere interpolated onto the ocean grid). These cell areas should be defined to enable exact calculation of global integrals (e.g., of vertical fluxes of energy at the surface and top of the atmosphere).
    frequency :
    fx
    id :
    areacello
    long_name :
    Grid-Cell Area for Ocean Variables
    mipTable :
    Ofx
    out_name :
    areacello
    prov :
    Ofx ((isd.003))
    realm :
    ocean
    standard_name :
    cell_area
    time_label :
    None
    time_title :
    No temporal dimensions ... fixed field
    title :
    Grid-Cell Area for Ocean Variables
    type :
    real
    units :
    m2
    variable_id :
    areacello
InΒ [31]:
# Let's calculate area-weighted mean global anomaly:
weighted_mean_global_anom = tos_anom.weighted(areacello).mean(dim=["lat", "lon"])
InΒ [32]:
unweighted_mean_global_anom.plot(size=7)
weighted_mean_global_anom.plot()
plt.legend(["unweighted", "weighted"])
plt.ylabel("global mean tos anomaly")
Out[32]:
Text(0, 0.5, 'global mean tos anomaly')
No description has been provided for this image

Carbon Cycle & the Greenhouse EffectΒΆ

image.png

InΒ [Β ]:
 

Climate FeedbacksΒΆ

image.png

InΒ [Β ]:
 

Past, Present & Future ClimateΒΆ

image.png image.png image.png

ResourcesΒΆ

Code and data for this tutorial is based on existing content from Project Pythia.